﻿#ifndef CHATLISTVIEWER_H
#define CHATLISTVIEWER_H

#include <QListView>

class ChatContent;

class ChatListViewer : public QListView
{
    Q_OBJECT
public:
    explicit ChatListViewer(QWidget *parent = nullptr);
    int showChat(bool fromSelf, const QPixmap &icon, const QString &name, const QString &content, qint64 timestamp = 0);
    int showImage(const QPixmap &icon, const QString &name, const QUrl &resourceName, const QPixmap &pixmap);
    int showImage(bool fromSelf, const QPixmap &icon, const QString &name, const QUrl &url, qint64 timestamp = 0);

    void initMid(const QByteArray& mid, int row, const QString &text);
    void setMidState(const QByteArray& mid, const QString &text);
    bool hasMid(const QByteArray& mid) const;

    void append(const QString &text);
    void clearAll();
protected:
    void contextMenuEvent(QContextMenuEvent *event);
    void resizeEvent(QResizeEvent * event);
signals:
    void appended();
    void cleared();
};

#endif // CHATLISTVIEWER_H
